package com.neuedu.mvc.filter;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class CharsetFilter implements Filter {

    public CharsetFilter( ) {
        System.out.println("CharsetFilter.CharsetFilter 构造");
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("CharsetFilter.init");
    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
        System.out.println("CharsetFilter.doFilter");


        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) resp;

        //chain 链式对象 ,放行请求
        chain.doFilter(req,resp);
    }

    @Override
    public void destroy( ) {
        System.out.println("CharsetFilter.destroy");
    }
}
